<?php

class Model_Site {
    
    public function getAllSite() {
        $sql = "Select * from site";
        $db = Model_Connections::getInstance()->getDbConnect();
        $data = $db->fetchAll($sql);
        return $data;
    }

    public function insertNewSite($siteName) {
        if ($siteName == null || $siteName == "")
            return false;
        else {
            $db = Model_Connections::getInstance()->getDbConnect();
            return $db->query("Insert into site(name) values('$siteName')");
        }
    }

    public function deleteSite($siteId) {
        if ($siteId == null || $siteId == "")
            return false;
        else {
            $db = Model_Connections::getInstance()->getDbConnect();
            return $db->query("DELETE FROM site WHERE id = '$siteId'");
        }
    }

    public function updateSite($id, $name) {
        if ($id == null || $id == "" || $name == null || $name == "")
            return false;
        else {
            $db = Model_Connections::getInstance()->getDbConnect();
            return $db->query("UPDATE site SET name='".$name."' WHERE id='".$id."'");
        }
    }

}

?>
